<template>
  <div>
    <!--基本信息  -->
    <el-dialog title="基本信息" :visible.sync="dialogProp.visible" :close-on-click-modal="false" @opened="listenOpenedDialog" @closed="listenClosedDialog">
      <el-form ref="dialogFormData" :model="dialogFormData" label-width="160px">
        <el-form-item label="所属部门:" prop="orgId">
          <el-cascader
            v-model="dialogFormData.orgId"
            :options="departmentList"
            :props="{ expandTrigger: 'hover',value: 'orgId',label: 'orgName',checkStrictly: true }"
            placeholder="暂无"
            disabled
          />
        </el-form-item>
        <el-form-item label="当前角色:" prop="roleId">
          <el-select v-model="dialogFormData.roleId" class="width-150" placeholder="暂无" disabled>
            <el-option v-for="item in roleList" :key="item.roleId" :label="item.roleName" :value="item.roleId" />
          </el-select>
        </el-form-item>
        <el-form-item label="用户姓名:" prop="chName">
          <el-input v-model.trim="dialogFormData.chName" clearable maxlength="50" disabled />
        </el-form-item>
        <el-form-item label="工号:" prop="username">
          <el-input v-model.trim="dialogFormData.username" clearable maxlength="50" disabled />
        </el-form-item>
        <!-- <el-form-item label="登录密码" prop="password">
          <el-input v-model.trim="dialogFormData.password" placeholder="请输入登录密码" clearable maxlength="50" />
        </el-form-item> -->

        <el-form-item label="员工性别:" prop="gender">
          <el-radio v-model="dialogFormData.gender" :label="1" disabled>男</el-radio>
          <el-radio v-model="dialogFormData.gender" :label="2" disabled>女</el-radio>
          <el-radio v-model="dialogFormData.gender" :label="0" disabled>保密</el-radio>
        </el-form-item>
        <el-form-item label="邮箱地址:" prop="email">
          <el-input v-model.trim="dialogFormData.email" clearable maxlength="50" disabled />
        </el-form-item>
        <el-form-item label="手机号码:" prop="mobile">
          <el-input v-model.trim="dialogFormData.mobile" clearable maxlength="50" disabled />
        </el-form-item>
        <!-- <el-form-item label="启用状态" prop="status">
          <el-select v-model="dialogFormData.status">
            <el-option :value="1" label="启用" />
            <el-option :value="0" label="关闭" />
          </el-select>
        </el-form-item> -->
        <el-form-item label="备注:" prop="remark">
          <el-input v-model.trim="dialogFormData.remark" type="textarea" maxlength="300" disabled />
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click.native="dialogProp.visible = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

import { findUserInfo } from '@/api/api'

export default {
  name: 'UserInfo',
  props: {
    // 弹窗属性相关数据(必传)
    dialogProp: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      // 部门数据
      departmentList: [],
      // 角色数据
      roleList: [],
      // 所选数据
      dialogFormData: {
        chName: '',
        username: '',
        password: '',
        orgId: '',
        roleId: '',
        gender: 1,
        email: '',
        mobile: '',
        status: 1,
        remark: ''
      }

    }
  },
  methods: {
    findUserInfo() {
      const params = {
        username: sessionStorage.getItem('username')
      }
      findUserInfo(params).then(res => {
        if (res.code === '0000') {
          this.dialogFormData = res.data
        }
      })
    },
    listenOpenedDialog() {
      this.findUserInfo()
      const tempList = this.Utils.deepCopy(this.$store.getters.departmentList)
      this.departmentList = this.Utils.isHasChildren(tempList)

      this.roleList = this.$store.getters.roleList
    },
    listenClosedDialog() {

    }

  }
}
</script>
<style lang="scss" scoped>
.user-box{
  border: 1px solid #ebeef5;
  padding:10px;
  height: 200px;
  overflow-y: auto;
  .user-item{
    height: 30px;
    line-height: 30px;
    border-bottom: 1px solid #ebeef5;
    .item-left{
      width: 85%;
      float: left;
      span{
        display: inline-block;
        width:49%;
      }
      .item-chName{
        width:35%;
      }
      .item-orgName{
        width:64%;
      }
    }
    .item-right{
      width: 14%;
      float: right;
      .item-icon{
        font-size: 20px;
        font-weight: bold;
        cursor: pointer;
        color:#F56C6C;
      }
      .item-icon:hover{
        color:#20a0ff;
      }
    }
  }
}

</style>
